package cn.wolfcode.user.service.impl;

import cn.wolfcode.user.dao.UserDAo;
import cn.wolfcode.user.dao.impl.UserDAOImpl;
import cn.wolfcode.user.entity.User;
import cn.wolfcode.user.service.UserService;

import java.util.List;

/**
 * @author 李新雨的项目86176
 * @version 1.0
 * @date 2024-10-28 20:51
 */
public class UserServiceImpl implements UserService{
    private UserDAo userDAO=new UserDAOImpl();
    @Override
    public User login(String username, String password) throws Exception{
        User user = userDAO.checkLogin(username, password);
        //// TODO: 2024/10/28   用户不存在，抛出异常
        if (user==null){
            throw new RuntimeException("用户名或密码错误");
        }
        return user;
    }

    @Override
    public void editHeadImg(User user) {
        userDAO.editHeadImg(user);
    }

    @Override
    public void insertInto(User user) {
        userDAO.insertInto(user);
    }

    @Override
    public List<String> selAllUserName() {
        return userDAO.selAllUserName();
    }

    @Override
    public void addNew(User user) {
        userDAO.addNew(user);
    }
}
